package thread.xianchengfengbixing;

import java.util.HashSet;
import java.util.Set;

/**
 * 在可变对象基础上构建的不可变类
 * */
public final class ThreeStooges {

    private static final Set<String> stooges = new HashSet<String>();

    public ThreeStooges(){

        stooges.add("sfy");
        stooges.add("zhongguo");
        stooges.add("songbing");

    }

    public boolean isStaore(String name){
        return stooges.contains(name);
    }


    public static void main(String[] args){

        ThreeStooges threeStooges = new ThreeStooges();
        boolean result = threeStooges.isStaore("sfy");
        System.out.println("result:"+result);
        stooges.add("sfsfsfsf");

        Set<String> test = stooges;
        test.stream().forEach(System.out::println);
    }

}
